package com.lyeducation.util;

import com.lyeducation.enums.CodeEnum;

/**
 * @ClassName EnumUtil
 * @Description
 * @Author Sky1in3
 * @Date 2019/1/11 17:33
 * @Version 1.0
 */
public class EnumUtil {
    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass){
        for (T each : enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())){
                return each;
            }
        }
        return null;
    }
}
